package com.aaa.sbm.controller;

import com.aaa.sbm.entity.Supplier;
import com.aaa.sbm.service.SupplierService;
import com.aaa.sbm.util.Page;
import com.aaa.sbm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Resource
    private SupplierService supplierService;

    @RequestMapping("/list")
    public Result list(@RequestBody(required = false) Page<Supplier> supplier) {
        return supplierService.getSupplierList(supplier);
    }

    @RequestMapping("/insertSupplier")
    public Result insert(@RequestBody(required = false) Supplier supplier) {
        return supplierService.insertSupplier(supplier);
    }

    @PostMapping("/updateSupplier")
    public Result update(@RequestBody(required = false) Supplier supplier) {
        return supplierService.updateSupplier(supplier);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        return supplierService.deleteSupplier(id);
    }

    @RequestMapping("/listStatus")
    public Result listStatus() {
        return supplierService.listStatus();
    }
}
